/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package org.abc;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * <p>Project: jse2303 - Format1
 * <p>Powered by webrx On @date 2023-07-10
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Format3 {
    public static void main(String[] args) throws Exception {
        long now = System.currentTimeMillis();
        System.out.printf("%tT %<tH %<tl %<tM %<tS %<tL %<tF %<tp %<ta %<tA %<tb %<tB%n", now);
        System.out.printf("%tR%n", now);

        //可以格式化Date Calendar long时间戳 ,也可以将字符串转换为Date对象
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String ff = sdf.format(0L);
        System.out.println(ff);

        //1997-06-15 18:20:30 建立一个date
        Date parse = sdf.parse("1997-06-15 18:20:30");
        System.out.printf("%tF %<tT", parse);

        System.out.println();
        SimpleDateFormat sdf2 = new SimpleDateFormat("MM月dd日");
        System.out.println(sdf2.format(new Date()));

        SimpleDateFormat sdf3 = new SimpleDateFormat("yyyyMMddHHmmssS");

        System.out.println(sdf3.format(System.currentTimeMillis()));


        DateTimeFormatter df = DateTimeFormatter.ofPattern("MMMMdd日 EEEE");
        System.out.println(LocalDate.now());
        String ss = df.format(LocalDate.now());
        System.out.println(ss);

        //LocalDate.format();
        System.out.println(LocalDate.of(1985, 10, 22).format(df));

        var sdf4 = new SimpleDateFormat("E EEEE MMMM M MM MMM");
        System.out.println(sdf4.format(new Date()));

        //要求输出 xxxx年xx月xx日 七月 星期一

        //将字符串按一定的格式，转换为LocalDateTime对象
        LocalDateTime ddd = LocalDateTime.parse("1985-11-22 18:20:30", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        System.out.println(ddd);


    }
}
